﻿using System;
using System.Configuration;
using System.Linq;
using Controllers;

namespace Web
{
    public partial class TrainSchemeInfo : System.Web.UI.Page
    {
        protected string isDisplay = "noDisplay";
        protected string deptName;
        protected void Page_Load(object sender, EventArgs e)
        {
            ApolloOaDataContext ctx = new ApolloOaDataContext(ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString);
            deptName = Request.QueryString["deptName"];

            EmpBasicInfo ebi = Session["ebi"] as EmpBasicInfo;
            string myDeptName = ctx.Depts.Single(r => r.Id == ebi.EmpDepPos.OrderByDescending(r2 => r2.PosId).First().DeptId).Text;
            if(!string.IsNullOrEmpty(deptName))
            {
                deptName = Server.UrlDecode(Request.QueryString["deptName"]);
            }
            else
            {
                deptName = myDeptName;
            }

            IQueryable<TrainScheme> list = from r in ctx.TrainSchemes where r.DeptName == deptName select r;
            rptList.DataSource = list;
            rptList.DataBind();
            if(deptName==myDeptName)
            {
                isDisplay =null;
            }
        }
    }
}